# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>

pkgname=python-reedsolo
pkgver=1.7.0
pkgrel=2
pkgdesc="A pure-python universal errors-and-erasures Reed-Solomon Codec"
arch=('loong64' 'x86_64')
url="https://github.com/tomerfiliba/reedsolomon"
license=('MIT')
makedepends=('python' 'cython')
depends=('python' 'python-setuptools')
source=($pkgname-$pkgver.tar.gz::https://github.com/tomerfiliba/reedsolomon/archive/v${pkgver}.tar.gz)
sha512sums=('c7d2ae8444c9e3d6646587f85fe0085a7579cc58d2f4bca3fb89632df4873e2664c81f06ee2e75e928248bb558a7fd8d101a043187ce05e70a079b031981c374')

prepare() {
  cd "reedsolomon-${pkgver}"
  # https://github.com/tomerfiliba/reedsolomon/issues/36
  # rm creedsolo.c
}

build() {
  cd "reedsolomon-${pkgver}"
  python3 setup.py build
}

check() {
  cd "reedsolomon-${pkgver}"
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  rm tests/test_creedsolo.py

  PYTHONPATH="$PWD/build/lib.linux-$CARCH-${python_version}" python -m unittest discover tests
}

package() {
  cd "reedsolomon-${pkgver}"
  python3 setup.py install --root="$pkgdir/" --optimize=1 --skip-build
  install -D -m0644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
